home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group98b.txt / 000127_icon-group-sender _Wed Jul 8 14:02:22 1998.msg < prev    next >
Internet Message Format  |  2000-09-20  |  2KB

  1. Return-Path: <icon-group-sender>
  2. Received: from kingfisher.CS.Arizona.EDU (kingfisher.CS.Arizona.EDU [192.12.69.239])
  3.     by baskerville.CS.Arizona.EDU (8.8.8/8.8.7) with SMTP id OAA02674
  4.     for <icon-group-addresses@baskerville.CS.Arizona.EDU>; Wed, 8 Jul 1998 14:02:16 -0700 (MST)
  5. Received: by kingfisher.CS.Arizona.EDU (5.65v4.0/1.1.8.2/08Nov94-0446PM)
  6.     id AA28049; Wed, 8 Jul 1998 14:02:03 -0700
  7. Message-Id: <199807081244.OAA00040@capway.com>
  8. From: "Vladimir Grodzenski" <grodzens@capway.com>
  9. To: David Starner <dstarner98@aasaa.ofe.org>
  10. Date: Wed, 8 Jul 1998 14:44:08 +0000
  11. Mime-Version: 1.0
  12. Content-Type: text/plain; charset=US-ASCII
  13. Content-Transfer-Encoding: 7BIT
  14. Subject: Re: Stripping excessive spaces
  15. Reply-To: <vladimir.grodzenski@capway.com>
  16. Cc: icon-group@optima.CS.Arizona.EDU
  17. Priority: urgent
  18. In-Reply-To: <35A2750A.E12A0673@aasaa.ofe.org>
  19. Errors-To: icon-group-errors@optima.CS.Arizona.EDU
  20. Status: RO
  21. Content-Length: 945
  22.  
  23. I'd write your procedure in this way:
  24.  
  25. procedure clip(s)
  26.    s ? {
  27.      tab(many(' '))
  28.      return trim(tab(0))
  29.     }
  30. end
  31.  
  32.  
  33. On  7 Jul 98 at 13:20, David Starner wrote:
  34. > I've just started programming in Icon, and I came across the problem
  35. > of removing all the starting and ending spaces from a string. This
  36. > was my solution, but I think it's terribly inefficent. Can some one
  37. > help me with a better way to do this?
  38. > procedure clip(s1)
  39. >  if type(s1) == "null" then fail
  40. >  s1 ?:= {
  41. >   tab(many(' ')) & tab(0)
  42. >   }
  43. >  s1 := reverse(s1)
  44. >  s1 ?:= {
  45. >   tab(many(' ')) & tab(0)
  46. >   }
  47. >  s1 := reverse(s1)
  48. >  return s1
  49. > end
  50. > -- 
  51. > David Starner - dvdeug@hotmail.com, dstarner98@aasaa.ofe.org
  52. > GURPS: http://www.geocities.com/TimesSquare/Ring/7895/
  53.  
  54. Vladimir Grodzenski
  55. =================================================
  56. E-mail: vladimir.grodzenski@capway.com
  57. CompuServe: 100700,526
  58. =================================================
  59.